<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0027)http://www.chinaidcard.com/ -->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta charset="UTF-8">
    <title>学员修改</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="css/layuiAdmin.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="js/constant.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->
</head>
<body>

<div class="layui-card xyxx">
    <div class="layui-card-header">学员基本信息</div>
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="component-form-element">

            <!--1-->
            <div class="layui-row layui-col-space10 layui-form-item">
                <div class="layui-col-md4">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-block" style="position: relative;">
                        <input type="text" name="Name"     class="layui-input" style="width: 55%; margin-right: 10px; float: left;">
                        <input id="Button1"  	class="layui-btn" type="button" value="读   卡" onclick="return Button1_onclick()" />
                        <img  src="" style="width: 91px; height: 108px" name="pic"/>
                    </div>
                </div>

                <div class="layui-col-md4">
                    <label class="layui-form-label">证件类型：</label>
                    <div class="layui-input-block">
                        <select name="sfType" id="sfType" lay-verify="required" lay-filter="aihao">
                            <option value="">请选择</option>

                        </select>
                    </div>
                </div>


                <div class="layui-col-md4">
                    <label class="layui-form-label">出生日期：</label>
                    <div class="layui-input-block">
                        <input type="text" name="Born"  class="layui-input" style="width: 55%; margin-right: 10px; float: left;">
                    </div>
                </div>
            </div>
            <!--1-->



            <!----2-->
            <div class="layui-form-item layui-row layui-col-space10">

                <div class="layui-col-md4">
                    <label class="layui-form-label">证件号码：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="CardNo">
                    </div>
                </div>

                <div class="layui-col-md4">
                    <label class="layui-form-label">国籍：</label>
                    <div class="layui-input-block">
                        <select name="country" lay-verify="required" lay-filter="aihao">
                            <option value="0">中国</option>
                            <option value="1"></option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">身份证有效期至：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="EffectedDate">至
                        <input type="text" class="layui-input" name="ExpiredDate">
                    </div>
                </div>

            </div>
            <!----2-->


            <!----3-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">性别：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="Sex">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">学习类别：</label>
                    <div class="layui-input-block " id="studyType">
                        <input type="radio" name="stu" value="add" title="增驾" >
                        <input type="radio" name="stu" value="first" title="初次申领">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">手机号码：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="phone">
                    </div>
                </div>
            </div>
            <!----3-->


            <!----4-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">准驾车型：</label>
                    <div class="layui-input-block">
                        <select name="carId" id="carId" lay-verify="required" lay-filter="aihao">
                            <option value="">请选择</option>

                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">暂住证编号：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="stayAddreeNumber">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">电子邮箱：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="email">
                    </div>
                </div>
            </div>
            <!----4-->


            <!----5-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">所属辖区：</label>
                    <div class="layui-input-block">
                        <select name="registeredAreaId" id="registeredAreaId" lay-verify="required">
                            <option value="" checked>请选择</option>

                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">

                    <label class="layui-form-label">住所详细地址：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="addressDetailed">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">报名来源：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="registeredSource">
                    </div>
                </div>
            </div>
            <!----5-->

            <!----6-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">登记住所行政区划：</label>
                    <div class="layui-input-block">
                        <select name="registeredRegionId" id="registeredRegionId" lay-verify="required" >

                        </select>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">登记住所详细地址：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="registeredResidence">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">来源：</label>
                    <div class="layui-input-block">
                        <!--  <input type="text" class="layui-input" name="field">-->
                        <input type="text" class="layui-input" name="local">
                    </div>
                </div>
            </div>
            <!----6-->
            <!----7-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">学费：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="registeredTuition">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">学员编号：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="studentNumber">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">报名日期：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="registeredTime" id="registeredTime">
                    </div>
                </div>
            </div>
            <!----7-->
            <!----8-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">(驾校)结构名称：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="driversId" value="2">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">推荐码：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="referralCode">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">待定：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" >
                    </div>
                </div>
            </div>
            <!----8-->
            <!----9-->
            <div class="layui-row layui-col-space10">
                <div class="layui-form-item layui-col-sm7">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="reason" placeholder="请输入内容" class="layui-textarea" style="min-height: 135px;"></textarea>
                    </div>
                </div>
            </div>
            <!----9-->

            <!----10-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">驾驶证申请表：</label>
                    <div class="layui-input-block">
                        <input type="text" name="driverDriver" class="layui-input" id="">
                    </div>

                </div>
                <div class="layui-col-md4">

                    <label class="layui-form-label">互联网面签协议：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="visaInterview">
                    </div>

                </div>
                <div class="layui-col-md4">

                    <label class="layui-form-label">指纹：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="fingerprint">
                    </div>

                </div>
            </div>
            <!----10-->

            <!----11-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">

                    <label class="layui-form-label">证件照：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="idPhoto">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">原驾驶证：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="originalDriverLicense">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">待定：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" >
                    </div>
                </div>
            </div>
            <!----11-->

            <!----12-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">民族：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="Nation" >
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">地址：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="Address">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">签发机关：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="IssuedAt" >
                    </div>
                </div>
            </div>
            <!----12-->

            <!----13-->
            <div class="layui-form-item layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <label class="layui-form-label">模块号码：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="SAMID" >
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">照片编码：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="Picture" >
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label">编码长度：</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="PictureLen" >
                    </div>
                </div>
            </div>
            <!----13-->

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="submitStudent">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </form>
    </div>
</div>
</div>
</div>
<OBJECT classid="clsid:10946843-7507-44FE-ACE8-2B3483D179B7"
        id="CVR_IDCard" name="CVR_IDCard" width="0" height="0" >
</OBJECT>




















<div style="text-align:center;" >
    <object classid="clsid:454C18E2-8B7D-43C6-8C17-B1825B49D7DE" id="captrue"  width="400" height="300" ></object>
</div>

<p>
<form method="POST" action="--WEBBOT-SELF--" name="form1">
    <input type="button" value="启动主" name="StartBtn" onclick="Start1_onclick()">
    <input type="button" value="启动副" name="StopBtn" onclick="Start2_onclick()">
    <input type="button" value="停止" name="StopBtn" onclick="Stop_onclick()">
    <input type="button" value="JPG" name="SaveJPGBtn" onclick="SaveJPG_onclick()">

</form>
</p>
</div>

</body>
<script src="../../layui/layui.js"></script>

<script language="javascript" type ="text/javascript">
    var sid;
    $(function () {
        //初始化
        sid=GetRequest().id;
        initBean(sid);



    });

    function ClearForm() {
        document.all['Name'].value = "";
        document.all['Sex'].value = "";
        document.all['Nation'].value = "";
        document.all['Born'].value = "";
        document.all['Address'].value = "";
        document.all['CardNo'].value = "";
        document.all['IssuedAt'].value = "";
        document.all['EffectedDate'].value = "";
        document.all['ExpiredDate'].value = "";
        document.all['SAMID'].value = "";
        document.all['pic'].src = "";
        document.all['Picture'].value = "";
        document.all['PictureLen'].value = "";
        return true;
    }
    function Button1_onclick() {
        var CVR_IDCard = document.getElementById("CVR_IDCard");
        var strReadResult = CVR_IDCard.ReadCard();
        if(strReadResult == "0")
        {
            ClearForm();
            document.all['Name'].value = CVR_IDCard.Name;
            document.all['Sex'].value = CVR_IDCard.Sex;
            document.all['Nation'].value = CVR_IDCard.Nation;
            document.all['Born'].value = CVR_IDCard.Born;
            document.all['Address'].value = CVR_IDCard.Address;
            document.all['CardNo'].value = CVR_IDCard.CardNo;
            document.all['IssuedAt'].value = CVR_IDCard.IssuedAt;
            document.all['EffectedDate'].value = CVR_IDCard.EffectedDate;
            document.all['ExpiredDate'].value = CVR_IDCard.ExpiredDate;
            document.all['SAMID'].value = CVR_IDCard.SAMID;
            document.all['pic'].src = CVR_IDCard.Pic;
            document.all['Picture'].value = CVR_IDCard.Picture;
            document.all['PictureLen'].value = CVR_IDCard.PictureLen
        }
        else
        {
            ClearForm();
            alert(strReadResult);
        }

    }


    function Button3_onclick() {
        var CVR_IDCard = document.getElementById("CVR_IDCard");
        CVR_IDCard.AboutBox();

    }
    function Start1_onclick()
    {
        var str=captrue.bStopPlay();
        var str = captrue.bStartPlay();
    }
    function Start2_onclick()
    {
        var str=captrue.bStopPlay();
        var str = captrue.bStartPlay2(0);
    }

    function Stop_onclick()
    {
        var str=captrue.bStopPlay();
    }

    function SaveJPG_onclick()
    {
        var str=captrue.bSaveJPG("D:\\","JPG");
    }
</script>


<script>

    var table;
    var pageData = null;
    layui.use(['table','form','laydate','layer'], function() {
        table = layui.table;
        var form = layui.form,
            laydate = layui.laydate,
            layer=layui.layer;

        //执行一个laydate实例
        laydate.render({
            elem: '#registeredTime' //指定元素
        });

        //监听提交
        form.on('submit(submitStudent)', function(data){
            ax.post({
                url:schoolWebUrl+"/api/student/update",
                data: JSON.stringify(saveBean()),
                success:function (res) {
                    if(res.code == CODE.ERROR)
                    {
                        layer.msg(res.message);
                    }
                    if (res.code == CODE.OK) {
                        //问题：  没有弹出信息框
                        layer.msg(res.message);
                        listStudent();
                    }

                },
                error : function(request) {
                    layer.msg("添加失败，请联系管理员！");
                }
            });
            return false;
        });

        var initBaseData = function () {
            ax.get({
                url: schoolWebUrl+"/api/student/getBaseData",
                success: function (res) {
                    if (res.code == 0) {
                        baseData = res.data;
                        loadBaseData();
                    } else {
                        layer.msg(res.message);
                    }
                }

            });
        };
        var loadBaseData = function () {

            //学习类型
            $("input[type=radio][name=stu]").val([pageData.studyType]);
            form.render(); //更新全部
            // 初始  证件
            $("#sfType").empty();
            $("#sfType").append("<option value='"+pageData.sfType+"'>"+pageData.sfTypeName+"</option>");
            $.each(baseData.zjTypeList, function (index, zj) {
                $("#sfType").append("<option value='" + zj.id + "'>" + zj.code + "</option>");
            });

            // 准驾车型列表
            $("#carId").empty();
            $("#carId").append("<option value='"+pageData.carId+"'>"+pageData.carName+"</option>");
            $.each(baseData.carTypeList, function (index, carType) {
                $("#carId").append("<option value='" + carType.id + "'>" + carType.code + "</option>");
            });

            // 所属辖区
            $("#registeredAreaId").empty();
            $("#registeredAreaId").append("<option value=''>请选择</option>");
            $.each(baseData.quyuAddressList, function (index, address) {
                $("#registeredAreaId").append("<option value='" + address.id + "'>" + address.code + "</option>");
            });

            //登记住所行政区划
            $("#registeredRegionId").empty();
            $("#registeredRegionId").append("<option value=''>请选择</option>");
            $.each(baseData.xzAddressTimeList, function (index, address) {
                $("#registeredRegionId").append("<option value='" + address.id + "'>" + address.code + "</option>");
            });
            form.render('select');
            baseDataDone = true;

        };



        initBaseData();

    });


    function saveBean() {
        var data= {
            id:sid,
            name : document.all['Name'].value,//姓名
            sex : document.all['Sex'].value,//性别
            nation : document.all['Nation'].value,//民族
            birthday : document.all['Born'].value,//出生日期：
            address : document.all['Address'].value,//地址  身份证上的地址
            certificatesNumber : document.all['CardNo'].value,//证件号码
            issuedAt : document.all['IssuedAt'].value,//签发机关
            effectedDate:document.all['EffectedDate'].value,//身份证有效期 开始
            expiredDate:document.all['ExpiredDate'].value,//身份证有效期 结束
            picture : "data:image/png;base64," + document.all['Picture'].value,//图片编码
            sfType : document.all['sfType'].value,//证件类型
            country : document.all['country'].value,//国籍
            studyType :$("input[name='stu']:checked").val(),//学习类别
            phone : document.all['phone'].value,//手机号码
            carId : document.all['carId'].value,//准驾车型
            stayAddreeNumber : document.all['stayAddreeNumber'].value,//暂住证编号：
            email : document.all['email'].value,//电子邮箱
            registeredAreaId : document.all['registeredAreaId'].value,//所属辖区
            addressDetailed : document.all['addressDetailed'].value,//住所详细地址：
            registeredSource : document.all['registeredSource'].value,//报名来源
            registeredRegionId : document.all['registeredRegionId'].value,//登记住所行政区划：
            registeredResidence : document.all['registeredResidence'].value,//登记住所详细地址：
            local : document.all['local'].value,//来源
            registeredTuition : document.all['registeredTuition'].value,//来源：：
            studentNumber : document.all['studentNumber'].value,//学员编号
            registeredTime : document.all['registeredTime'].value,//报名日期
            driversId : document.all['driversId'].value,//(驾校)结构名称
            referralCode : document.all['referralCode'].value,//(推荐码
            reason : document.all['reason'].value,//(备注
            driverDriver : document.all['driverDriver'].value,//驾驶证申请表
            visaInterview : document.all['visaInterview'].value,//互联网面签协议
            fingerprint : document.all['fingerprint'].value,//指纹：
            idPhoto : document.all['idPhoto'].value,//证件照
            originalDriverLicense : document.all['originalDriverLicense'].value,//原驾驶证

        }


        return data;
    }


    function  listStudent() {
        window.location.href='studentList.html';
    }

    
    function  initBean(id) {

        var  data={studentId:id};
        ax.get({
            url:schoolWebUrl+"/api/student/getStudentById",
            data: data,
            success:function (res) {
                if (res.code == CODE.OK) {
                    pageData = res.data;
                    initBeanData(res.data);
                }
                if(res.code == CODE.ERROR)
                {
                    layer.msg(res.message);
                }
            },
            error : function(request) {
                layer.msg("修改失败，请联系管理员！");
            }
        });
    }

    function  initBeanData(data){
            document.all['Name'].value=data.name,//姓名
            document.all['Sex'].value=data.sex,//性别
            document.all['Nation'].value=data.nation,//民族
            document.all['Born'].value=data.birthday,//出生日期：
            document.all['Address'].value=data.address,//地址  身份证上的地址
            document.all['CardNo'].value=data.certificatesNumber+"",//证件号码
            document.all['IssuedAt'].value=data.issuedAt,//签发机关
            document.all['EffectedDate'].value=data.effectedDate,//身份证有效期 开始
            document.all['ExpiredDate'].value=data.expiredDate,//身份证有效期 结束
            document.all['Picture'].value="data:image/png;base64," +data.picture,//图片编码
            document.all['sfType'].value=data.sfType,//证件类型
            document.all['country'].value=data.country,//国籍
          //  document.all['stu'].value=data.sfType,//学习类别
            document.all['phone'].value=data.phone,//手机号码
            document.all['carId'].value=data.carId,//准驾车型
            document.all['stayAddreeNumber'].value=data.stayAddreeNumber,//暂住证编号：
            document.all['email'].value=data.email,//电子邮箱
            document.all['registeredAreaId'].value=data.registeredAreaId,//所属辖区
            document.all['addressDetailed'].value=data.addressDetailed,//住所详细地址：
            document.all['registeredSource'].value=data.registeredSource,//报名来源
            document.all['registeredRegionId'].value=data.registeredRegionId,//登记住所行政区划：
            document.all['registeredResidence'].value=data.registeredResidence,//登记住所详细地址：
            document.all['local'].value=data.local,//来源
            document.all['registeredTuition'].value=data.registeredTuition,//来源：：
            document.all['studentNumber'].value=data.studentNumber,//学员编号
            document.all['registeredTime'].value=data.registeredTime,//报名日期
            document.all['driversId'].value=data.driversId,//(驾校)结构名称
            document.all['referralCode'].value=data.referralCode,//(推荐码
            document.all['reason'].value=data.reason,//(备注
            document.all['driverDriver'].value=data.driverDriver,//驾驶证申请表
            document.all['visaInterview'].value=data.visaInterview,//互联网面签协议
            document.all['fingerprint'].value=data.fingerprint,//指纹：
            document.all['idPhoto'].value=data.idPhoto,//证件照
            document.all['originalDriverLicense'].value=data.originalDriverLicense//原驾驶证


    }
    
</script>
</html>
